package net.homeip.mmhg.game;

import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.StatefulJob;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * Show notification at the time.
 * 
 * @author gerasimov ilya
 */
public class ShowNotificationJob implements StatefulJob {

	public static final String NOTIF_ID = "notification";
	private GameContext gameContext;
	
	@Autowired
	public void setGameContext(GameContext context) {
		gameContext = context;
	}
	
	@Override
	public void execute(JobExecutionContext context) throws JobExecutionException {
		try {
			JobDataMap dataMap = context.getMergedJobDataMap();
			gameContext.showNotification((Integer) dataMap.get(NOTIF_ID));
		} catch (Throwable throwable) {
			throw new JobExecutionException(throwable);
		}
	}

}
